"""Pydantic schemas for user & auth related operations."""

from __future__ import annotations

from datetime import datetime
from typing import Optional

from pydantic import BaseModel, Field


class UserRegister(BaseModel):
    username: str = Field(min_length=3, max_length=32)
    password: str = Field(min_length=6, max_length=128)
    # email removed / optional for Phase 1 – can be added later


class UserLogin(BaseModel):
    username: str
    password: str


class GuestLoginRequest(BaseModel):
    """Empty body placeholder (extensible)."""

    pass


class UserProfile(BaseModel):
    id: int
    username: str
    avatar_url: Optional[str] = None
    is_active: bool
    is_guest: bool
    is_admin: bool = False
    created_at: datetime

    class Config:
        from_attributes = True


class TokenResponse(BaseModel):
    access_token: str
    token_type: str = "bearer"
    expires_in: int
    is_guest: bool
    username: str


class PasswordUpdate(BaseModel):
    old_password: str
    new_password: str = Field(min_length=6, max_length=128)


class AvatarUrlUpdate(BaseModel):
    avatar_url: str = Field(max_length=512)


class Message(BaseModel):
    message: str
